//键盘操作
$(document).ready(function() {
	$(document).keydown(function (event) {
		var $dropdownMenu = $('ul.goods-dropdown-menu');
//	$('div.dropdown').keydown(function (event) { // 缩小事件注册范围
//		var $dropdownMenu = $(this).find('ul.goods-dropdown-menu');
		if ($dropdownMenu && $dropdownMenu.length) {
			var $active = $dropdownMenu.find('tr.active');
			if ($active && $active.length) {
				switch (event.keyCode) {
			    case 13: // Enter
			    	$active.click();
			        break;
			    case 38: // 方向键-上
			    	var $up = $active.prev('tr');
			    	if ($up && $up.length) {
			    		$up.addClass('active');
			    		$active.removeClass('active');
			    		
			    		// 滚动条
			    		$dropdownMenu.scrollTop($dropdownMenu.scrollTop() - $active.height());
			    	}
			        break;
			    case 40: // 方向键-下
			    	var $down = $active.next('tr');
			    	if ($down && $down.length) {
			    		$down.addClass('active');
			    		$active.removeClass('active');
			    		
			    		// 滚动条
			    		$dropdownMenu.scrollTop($dropdownMenu.scrollTop() + $active.height());
			    	}
			        break;
			    };
			}
		}
		
	    return true;
	});
});